#define _CRT_SECURE_NO_WARNINGS

int postorderTraversalS(struct TreeNode* root)
{
    if (root == NULL)
        return 0;

    return postorderTraversalS(root->left) + postorderTraversalS(root->right) + 1;
}

void _postorderTraversal(struct TreeNode* root, int* returnSize, int* tmp)
{
    if (root == NULL)
        return;
    _postorderTraversal(root->left, returnSize, tmp);
    _postorderTraversal(root->right, returnSize, tmp);
    tmp[(*returnSize)++] = root->val;
}

int* postorderTraversal(struct TreeNode* root, int* returnSize)
{
    int size = postorderTraversalS(root);
    int* tmp = (int*)malloc(sizeof(int) * size);
    *returnSize = 0;
    _postorderTraversal(root, returnSize, tmp);
    return tmp;
}